package com.example.Proxy2;

import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;


import java.lang.reflect.Method;


/**
 * @version: java version 23
 * @Author: 韩学新
 * @description:
 * @date: 2025-05-21 上午9:55
 */
@Slf4j
public class MyMethodInterceptor implements MethodInterceptor {

    /**
     * cglib
     * @param o
     * @param method
     * @param objects
     * @param methodProxy
     * @return
     * @throws Throwable
     */
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        log.info("<在目标方法执行前");
        Object result = methodProxy.invokeSuper(o, objects);
        log.info("<在目标方法执行后");
        return result;
    }
}
